clear;clc;

Temp    =   load("Results_AltFiscalPolicy.mat");

TempList    =   {Temp.SOLUTION, Temp.SOLUTION_T, Temp.SOLUTION_G, Temp.SOLUTION_TAU_RealB};
LabelList   =   {'Baseline-TAU','T','G','Baseline-RealB'};

TempNum     =   length(TempList);
Tables      =   cell(TempNum,1);

parfor ii=1:TempNum
    vv          =   TempList{ii};
    Tables{ii}  =   SubFun_CollectResults(vv);
end

FileName    =   'TableGraphs\\ModelExtension_AltFiscalPolicy.xlsx';
ShockList   =   {'Eps_Eta_M_dom', 'Eps_Eta_Y_H', 'Eps_Eta_M_ext'};
for ii=1:length(ShockList)
    SH          =   ShockList{ii};
    TempData    =   [];
    for jj=1:TempNum
        TempData    =   [TempData,Tables{jj}.(SH)];
    end
    TempTable   =   array2table(TempData,'VariableNames',LabelList,'RowNames',Tables{1}.Row);
    writetable(TempTable,FileName,'WriteRowNames',true,'Sheet',SH);
end

%% Extra Details 
% Price level 
plot(cumsum(Temp.SOLUTION.IRF.Eps_Eta_M_dom.Pir(1:40))*100, 'linewidth',3);
hold on;
plot(cumsum(Temp.SOLUTION_TAU_RealB.IRF.Eps_Eta_M_dom.Pir(1:40))*100, 'linewidth',3);
hold on;
plot(cumsum(Temp.SOLUTION_TAU_RealB.IRF.Eps_Eta_M_dom.Pir(1:40))*100 - ...
     cumsum(Temp.SOLUTION.IRF.Eps_Eta_M_dom.Pir(1:40))*100, 'linewidth',3);
legend("Baseline", "Real B", "Diff: Real B - Baseline");